<template>
    <!-- 
    <b-modal ref="my-modal" hide-footer title="Using Component Methods">
     <div class="d-block text-center">
       <h3>Hello From My Modal!</h3>
     </div>
     <b-button class="mt-3" variant="outline-danger" block @click="hideModal">Close Me</b-button>
     <b-button class="mt-2" variant="outline-warning" block @click="toggleModal">Toggle Me</b-button>
   </b-modal> 
    -->
    <!--
        body-class="modalStyle" 表示样式
        size="lg" 表示模态窗口大小 xl,lg,sm,full
        hide-footer 表示隐藏底部按钮
        hide-header 表示隐藏头部内容
        no-close-on-backdrop 表示鼠标点击背景不可关闭
        hide-header-close 表示隐藏头部关闭按钮
        centered 居中
        ok-title=“确定” 
        cancel-title=取消
        @ok="handleOk" 
        @cancel="handleCancel"
        scrollable 滚动条
        hide-backdrop 隐藏背景
        wrapClassName="ant-modal-cust-warp" 
        style="top:5%;height: 85%;overflow-y: hidden" 样式
        :modal-class="my-modal"
        dialog-class="modal-dialog"
        @hidden 关闭窗体触发事件
    -->
    <b-modal ref="my-modal" body-class="lcModalBodyClass" :title="title" scrollable content-class="fullWinBody" @hidden="onHidden" size="fullWin" centered hide-footer no-close-on-backdrop >
        <div class="d-block text-center" style="height: 99%;">
            <iframe ref="lcDesignWinIframe" :src="iframeSrc" style="height: 100%;" width="100%" frameborder="0"></iframe>
        </div>
        <template slot="modal-footer">
            <!--自定义按钮-->
        </template>
    </b-modal>    
</template>
<script>
import apiUtil from "@/core/util/apiUtil.js";
import { handleNotify,handleAlert,handleConfirm,showWating,closeWating} from "@/core/util/jehcUtil.js";
export default {
    data(){
        return {
            title:"在线设计",
            id:"",
            iframeSrc:process.env.BASE_URL+"deng/view/workflow/lc-design2.0/index.html",
            height:KTUtil.getViewPort().height-100,
        }
    },
    components: {
    },
    watch: {
    },
    mounted() {        
       
    },
    methods: {        
        showModal(row) {
            this.$refs['my-modal'].show();
            this.id = "";
            this.title = "在线设计";
            this.iframeSrc = process.env.BASE_URL+"deng/view/workflow/lc-design2.0/index.html";
            if(null != row && undefined != row){
                this.id = row.id;
                this.title = "在线设计【"+row.title+"】";
                this.iframeSrc = process.env.BASE_URL+"deng/view/workflow/lc-design2.0/index.html?id="+this.id
            }
            setTimeout(() => {
                this.initIframeWin();
            }, 100);
        },
        hideModal() {
            this.$refs['my-modal'].hide()
        },
        toggleModal() {
            // 当模态已隐藏时，我们传递要返回焦点的按钮的ID
            this.$refs['my-modal'].toggle('#toggle-btn')
        },
        onHidden(){//关闭窗体触发事件
            this.$emit("change",null);
        },
        initIframeWin() {
            let oauthModules = process.env.VUE_APP_OAUTH_API;

            //监控中心API
            let monitorModules = process.env.VUE_APP_MONITOR_API;

            //运维中心API
            let opModules = process.env.VUE_APP_OP_API;

            //平台中心API
            let sysModules = process.env.VUE_APP_SYS_API;

            //工作流中心API
            let workflowModules = process.env.VUE_APP_WORKFLOW_API;

            //文件中心API
            let fileModules = process.env.VUE_APP_FILE_API;

            //日志中心API
            let logModules = process.env.VUE_APP_LOG_API;

            //即时通讯中心API
            let imModules = process.env.VUE_APP_IM_API;

            //即时通讯中心WebSocket
            let imWebSocketModules = process.env.VUE_APP_IM_WEBSOCKET_API;

            //报表中心API
            let reportModules = process.env.VUE_APP_REPORT_API;

            //调度中心API
            let jobModules = process.env.VUE_APP_JOB_API;

            //病历云API
            let medicalModules = process.env.VUE_APP_MEDICAL_API;

            //运管平台API
            let ompModules =process.env. VUE_APP_OMP_API;

            const lcDesignIframe = this.$refs.lcDesignWinIframe;
            // 因为iframe页面打开就已经加载 获取接口成功后刷新他                   
            lcDesignIframe.contentWindow.location.reload()
            let params = { 
                oauthModules: oauthModules, 
                monitorModules: monitorModules,
                opModules:opModules,
                sysModules:sysModules,
                workflowModules:workflowModules,
                fileModules:fileModules,
                logModules:logModules,
                imModules:imModules,
                imWebSocketModules:imWebSocketModules,
                reportModules:reportModules,
                jobModules:jobModules,
                medicalModules:medicalModules,
                ompModules:ompModules,
                basePath: process.env.BASE_URL 
            }
            if (lcDesignIframe.attachEvent) {
                // 兼容浏览器判断 // iframe的加载完成函数         
                lcDesignIframe.attachEvent('onload', function () {
                    const iframeWin = lcDesignIframe.contentWindow
                    //传递参数           
                    iframeWin.postMessage(params, '*')
                })
            } else {
                // iframe的加载完成函数         
                lcDesignIframe.onload = function () {
                    const iframeWin = lcDesignIframe.contentWindow
                    console.log(iframeWin);
                    //传递参数           
                    iframeWin.postMessage(params, '*')
                }
            }
        },
   }
}
</script>

<style>
.lcModalBodyClass{
    padding:0px !important
}
</style>